CREATE DATABASE SURVEYHOST ON  PRIMARY 
( NAME = N'SurveyHost', FILENAME = @dataPath + N'SurveyHost.mdf' , SIZE = 3264KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
 LOG ON 
( NAME = N'SurveyHost_log', FILENAME = @dataPath + N'SurveyHost_log.ldf' , SIZE = 768KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
 COLLATE SQL_Latin1_General_CP1_CI_AS
EXEC dbo.sp_dbcmptlevel @dbname= @dataPath + N'SurveyHost.mdf' , @new_cmptlevel=90
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC SURVEYHOST.[dbo].[sp_fulltext_database] @action = 'enable'
end
ALTER DATABASE SURVEYHOST SET ANSI_NULL_DEFAULT OFF 
ALTER DATABASE SURVEYHOST SET ANSI_NULLS OFF 
ALTER DATABASE SURVEYHOST SET ANSI_PADDING OFF 
ALTER DATABASE SURVEYHOST SET ANSI_WARNINGS OFF 
ALTER DATABASE SURVEYHOST SET ARITHABORT OFF 
ALTER DATABASE SURVEYHOST SET AUTO_CLOSE ON 
ALTER DATABASE SURVEYHOST SET AUTO_CREATE_STATISTICS ON 
ALTER DATABASE SURVEYHOST SET AUTO_SHRINK OFF 
ALTER DATABASE SURVEYHOST SET AUTO_UPDATE_STATISTICS ON 
ALTER DATABASE SURVEYHOST SET CURSOR_CLOSE_ON_COMMIT OFF 
ALTER DATABASE SURVEYHOST SET CURSOR_DEFAULT  GLOBAL 
ALTER DATABASE SURVEYHOST SET CONCAT_NULL_YIELDS_NULL OFF 
ALTER DATABASE SURVEYHOST SET NUMERIC_ROUNDABORT OFF 
ALTER DATABASE SURVEYHOST SET QUOTED_IDENTIFIER OFF 
ALTER DATABASE SURVEYHOST SET RECURSIVE_TRIGGERS OFF 
ALTER DATABASE SURVEYHOST SET  DISABLE_BROKER 
ALTER DATABASE SURVEYHOST SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
ALTER DATABASE SURVEYHOST SET DATE_CORRELATION_OPTIMIZATION OFF 
ALTER DATABASE SURVEYHOST SET TRUSTWORTHY OFF 
ALTER DATABASE SURVEYHOST SET ALLOW_SNAPSHOT_ISOLATION OFF 
ALTER DATABASE SURVEYHOST SET PARAMETERIZATION SIMPLE 
ALTER DATABASE SURVEYHOST SET  READ_WRITE 
ALTER DATABASE SURVEYHOST SET RECOVERY FULL 
ALTER DATABASE SURVEYHOST SET  MULTI_USER 
ALTER DATABASE SURVEYHOST SET PAGE_VERIFY NONE  
ALTER DATABASE SURVEYHOST SET DB_CHAINING OFF 
USE SURVEYHOST
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[Answer](
	[SurveyId] [uniqueidentifier] NOT NULL,
	[StemId] [uniqueidentifier] NOT NULL,
	[AnswerText] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_Answer_1] PRIMARY KEY CLUSTERED 
(
	[SurveyId] ASC,
	[StemId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_PADDING OFF

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[AnswerObjectType](
	[AnswerTypeName] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[AssemblyQualifiedName] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[AnswerConfigurationHelpText] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_AnswerObjectType] PRIMARY KEY CLUSTERED 
(
	[AnswerTypeName] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_PADDING OFF

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_Applications](
	[ApplicationName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[LoweredApplicationName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ApplicationId] [uniqueidentifier] NOT NULL DEFAULT (newid()),
	[Description] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
PRIMARY KEY NONCLUSTERED 
(
	[ApplicationId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[LoweredApplicationName] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY],
UNIQUE NONCLUSTERED 
(
	[ApplicationName] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_Membership](
	[ApplicationId] [uniqueidentifier] NOT NULL,
	[UserId] [uniqueidentifier] NOT NULL,
	[Password] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PasswordFormat] [int] NOT NULL DEFAULT ((0)),
	[PasswordSalt] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[MobilePIN] [nvarchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Email] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[LoweredEmail] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PasswordQuestion] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PasswordAnswer] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[IsApproved] [bit] NOT NULL,
	[IsLockedOut] [bit] NOT NULL,
	[CreateDate] [datetime] NOT NULL,
	[LastLoginDate] [datetime] NOT NULL,
	[LastPasswordChangedDate] [datetime] NOT NULL,
	[LastLockoutDate] [datetime] NOT NULL,
	[FailedPasswordAttemptCount] [int] NOT NULL,
	[FailedPasswordAttemptWindowStart] [datetime] NOT NULL,
	[FailedPasswordAnswerAttemptCount] [int] NOT NULL,
	[FailedPasswordAnswerAttemptWindowStart] [datetime] NOT NULL,
	[Comment] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
PRIMARY KEY NONCLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_Paths](
	[ApplicationId] [uniqueidentifier] NOT NULL,
	[PathId] [uniqueidentifier] NOT NULL DEFAULT (newid()),
	[Path] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[LoweredPath] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
PRIMARY KEY NONCLUSTERED 
(
	[PathId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_PersonalizationAllUsers](
	[PathId] [uniqueidentifier] NOT NULL,
	[PageSettings] [image] NOT NULL,
	[LastUpdatedDate] [datetime] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[PathId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_PersonalizationPerUser](
	[Id] [uniqueidentifier] NOT NULL DEFAULT (newid()),
	[PathId] [uniqueidentifier] NULL,
	[UserId] [uniqueidentifier] NULL,
	[PageSettings] [image] NOT NULL,
	[LastUpdatedDate] [datetime] NOT NULL,
PRIMARY KEY NONCLUSTERED 
(
	[Id] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_Profile](
	[UserId] [uniqueidentifier] NOT NULL,
	[PropertyNames] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PropertyValuesString] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[PropertyValuesBinary] [image] NOT NULL,
	[LastUpdatedDate] [datetime] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_Roles](
	[ApplicationId] [uniqueidentifier] NOT NULL,
	[RoleId] [uniqueidentifier] NOT NULL DEFAULT (newid()),
	[RoleName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[LoweredRoleName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Description] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
PRIMARY KEY NONCLUSTERED 
(
	[RoleId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_SchemaVersions](
	[Feature] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CompatibleSchemaVersion] [nvarchar](128) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[IsCurrentVersion] [bit] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[Feature] ASC,
	[CompatibleSchemaVersion] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_Users](
	[ApplicationId] [uniqueidentifier] NOT NULL,
	[UserId] [uniqueidentifier] NOT NULL DEFAULT (newid()),
	[UserName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[LoweredUserName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[MobileAlias] [nvarchar](16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL DEFAULT (NULL),
	[IsAnonymous] [bit] NOT NULL DEFAULT ((0)),
	[LastActivityDate] [datetime] NOT NULL,
PRIMARY KEY NONCLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[aspnet_UsersInRoles](
	[UserId] [uniqueidentifier] NOT NULL,
	[RoleId] [uniqueidentifier] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[UserId] ASC,
	[RoleId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[aspnet_WebEvent_Events](
	[EventId] [char](32) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[EventTimeUtc] [datetime] NOT NULL,
	[EventTime] [datetime] NOT NULL,
	[EventType] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[EventSequence] [decimal](19, 0) NOT NULL,
	[EventOccurrence] [decimal](19, 0) NOT NULL,
	[EventCode] [int] NOT NULL,
	[EventDetailCode] [int] NOT NULL,
	[Message] [nvarchar](1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ApplicationPath] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ApplicationVirtualPath] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[MachineName] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[RequestUrl] [nvarchar](1024) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ExceptionType] [nvarchar](256) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Details] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
PRIMARY KEY CLUSTERED 
(
	[EventId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

SET ANSI_PADDING OFF

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[Category](
	[CategoryID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryName] [nvarchar](64) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
 CONSTRAINT [PK_Categories] PRIMARY KEY CLUSTERED 
(
	[CategoryID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[CategoryLog](
	[CategoryLogID] [int] IDENTITY(1,1) NOT NULL,
	[CategoryID] [int] NOT NULL,
	[LogID] [int] NOT NULL,
 CONSTRAINT [PK_CategoryLog] PRIMARY KEY CLUSTERED 
(
	[CategoryLogID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[Content](
	[ContentId] [int] IDENTITY(1,1) NOT NULL,
	[ContentGUID] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Content_ContentGUID]  DEFAULT (newid()),
	[Title] [nvarchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ContentName] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Body] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Locale] [nvarchar](7) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_Content_Locale]  DEFAULT (N'en-US'),
	[CreatedOn] [datetime] NULL CONSTRAINT [DF_Content_CreatedOn]  DEFAULT (getdate()),
	[CreatedBy] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ModifiedOn] [datetime] NULL CONSTRAINT [DF_Content_ModifiedOn]  DEFAULT (getdate()),
	[ModifiedBy] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Content] PRIMARY KEY CLUSTERED 
(
	[ContentId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[HostConfiguration](
	[SurveyName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[HostName] [varchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[AdministratorName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[InvitationEmail] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[CompletionEmail] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[AdministratorPublicEmail] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[AdministratorPrivateEmail] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ScreenApplicant] [bit] NOT NULL CONSTRAINT [DF_HostConfiguration_ScreenApplicant]  DEFAULT ((0)),
	[SMTPHost] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[SMTPPort] [int] NULL,
	[SMTPLoginName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[SMTPLoginPassword] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[SMTPUseSSL] [bit] NOT NULL CONSTRAINT [DF_HostConfiguration_SMTPUseSSL]  DEFAULT ((1)),
 CONSTRAINT [PK_HostConfiguration] PRIMARY KEY CLUSTERED 
(
	[SurveyName] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_PADDING OFF
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Survey name' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HostConfiguration', @level2type=N'COLUMN',@level2name=N'SurveyName'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Survey administrator''s name' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HostConfiguration', @level2type=N'COLUMN',@level2name=N'AdministratorName'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Invitation email' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HostConfiguration', @level2type=N'COLUMN',@level2name=N'InvitationEmail'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Survey completed email' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HostConfiguration', @level2type=N'COLUMN',@level2name=N'CompletionEmail'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The survey administrator''s public email' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HostConfiguration', @level2type=N'COLUMN',@level2name=N'AdministratorPublicEmail'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'The survey administrator''s private email' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HostConfiguration', @level2type=N'COLUMN',@level2name=N'AdministratorPrivateEmail'
EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'Perform applicant screening' , @level0type=N'SCHEMA',@level0name=N'dbo', @level1type=N'TABLE',@level1name=N'HostConfiguration', @level2type=N'COLUMN',@level2name=N'ScreenApplicant'

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[Measure](
	[MeasureName] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Rank] [int] NOT NULL CONSTRAINT [DF_Measure_Rank]  DEFAULT ((0)),
	[DefaultAnswerTypeName] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Instructions] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Measure] PRIMARY KEY CLUSTERED 
(
	[MeasureName] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_PADDING OFF

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[Settings](
	[Id] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Settings_Id]  DEFAULT (newid()),
	[EmailCC] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[SurveyName] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_Settings_SurveyName]  DEFAULT ('SurveyHost.NET'),
	[SurveyByline] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL CONSTRAINT [DF_Settings_SurveyByline]  DEFAULT ('Online professional survey hosting website'),
	[EmailSubject] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[EmailMessage] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]

SET ANSI_PADDING OFF

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[Stem](
	[StemId] [uniqueidentifier] NOT NULL CONSTRAINT [DF_Question_QuestionId]  DEFAULT (newid()),
	[MeasureName] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[QuestionText] [varchar](1000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Rank] [int] NOT NULL CONSTRAINT [DF_Question_Rank]  DEFAULT ((0)),
	[AnswerTypeName] [varchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[AnswerTypeConfiguration] [varchar](500) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Question] PRIMARY KEY CLUSTERED 
(
	[StemId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_PADDING OFF

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[Survey](
	[SurveyId] [uniqueidentifier] NOT NULL,
	[BeginTime] [datetime] NOT NULL CONSTRAINT [DF_Survey_BeginTime]  DEFAULT (getdate()),
	[EndTime] [datetime] NULL,
 CONSTRAINT [PK_Survey] PRIMARY KEY CLUSTERED 
(
	[SurveyId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
SET ANSI_PADDING ON
CREATE TABLE [dbo].[UserStatus](
	[UserId] [uniqueidentifier] NOT NULL,
	[EnteredName] [varchar](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[ConsentDate] [datetime] NOT NULL CONSTRAINT [DF_Consent_RecordedDate]  DEFAULT (getdate()),
	[Completed] [bit] NOT NULL CONSTRAINT [DF_UserStatus_Completed]  DEFAULT ((0)),
	[AreOrOver18] [bit] NOT NULL CONSTRAINT [DF_UserStatus_AreOrOver18]  DEFAULT ((0)),
	[RelationshipInPastYear] [bit] NOT NULL CONSTRAINT [DF_UserStatus_RelationshipInPastYear]  DEFAULT ((0)),
	[ValidationComplete] [bit] NOT NULL CONSTRAINT [DF_UserStatus_ValidationComplete]  DEFAULT ((0)),
 CONSTRAINT [PK_Consent] PRIMARY KEY CLUSTERED 
(
	[UserId] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

SET ANSI_PADDING OFF
ALTER TABLE [dbo].[Answer]  WITH CHECK ADD  CONSTRAINT [FK_Answer_Question] FOREIGN KEY([StemId])
REFERENCES [dbo].[Stem] ([StemId])
ALTER TABLE [dbo].[Answer] CHECK CONSTRAINT [FK_Answer_Question]
ALTER TABLE [dbo].[Answer]  WITH CHECK ADD  CONSTRAINT [FK_Answer_Survey] FOREIGN KEY([SurveyId])
REFERENCES [dbo].[Survey] ([SurveyId])
ALTER TABLE [dbo].[Answer] CHECK CONSTRAINT [FK_Answer_Survey]
ALTER TABLE [dbo].[aspnet_Membership]  WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
ALTER TABLE [dbo].[aspnet_Membership]  WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
ALTER TABLE [dbo].[aspnet_Paths]  WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
ALTER TABLE [dbo].[aspnet_PersonalizationAllUsers]  WITH CHECK ADD FOREIGN KEY([PathId])
REFERENCES [dbo].[aspnet_Paths] ([PathId])
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser]  WITH CHECK ADD FOREIGN KEY([PathId])
REFERENCES [dbo].[aspnet_Paths] ([PathId])
ALTER TABLE [dbo].[aspnet_PersonalizationPerUser]  WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
ALTER TABLE [dbo].[aspnet_Profile]  WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
ALTER TABLE [dbo].[aspnet_Roles]  WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
ALTER TABLE [dbo].[aspnet_Users]  WITH CHECK ADD FOREIGN KEY([ApplicationId])
REFERENCES [dbo].[aspnet_Applications] ([ApplicationId])
ALTER TABLE [dbo].[aspnet_UsersInRoles]  WITH CHECK ADD FOREIGN KEY([RoleId])
REFERENCES [dbo].[aspnet_Roles] ([RoleId])
ALTER TABLE [dbo].[aspnet_UsersInRoles]  WITH CHECK ADD FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
ALTER TABLE [dbo].[CategoryLog]  WITH CHECK ADD  CONSTRAINT [FK_CategoryLog_Category] FOREIGN KEY([CategoryID])
REFERENCES [dbo].[Category] ([CategoryID])
ALTER TABLE [dbo].[CategoryLog] CHECK CONSTRAINT [FK_CategoryLog_Category]
ALTER TABLE [dbo].[CategoryLog]  WITH CHECK ADD  CONSTRAINT [FK_CategoryLog_Log] FOREIGN KEY([LogID])
REFERENCES [dbo].[Log] ([LogID])
ALTER TABLE [dbo].[CategoryLog] CHECK CONSTRAINT [FK_CategoryLog_Log]
ALTER TABLE [dbo].[Measure]  WITH CHECK ADD  CONSTRAINT [FK_Measure_AnswerObjectType] FOREIGN KEY([DefaultAnswerTypeName])
REFERENCES [dbo].[AnswerObjectType] ([AnswerTypeName])
ALTER TABLE [dbo].[Measure] CHECK CONSTRAINT [FK_Measure_AnswerObjectType]
ALTER TABLE [dbo].[Stem]  WITH CHECK ADD  CONSTRAINT [FK_Measure_Question] FOREIGN KEY([MeasureName])
REFERENCES [dbo].[Measure] ([MeasureName])
ALTER TABLE [dbo].[Stem] CHECK CONSTRAINT [FK_Measure_Question]
ALTER TABLE [dbo].[Stem]  WITH CHECK ADD  CONSTRAINT [FK_Question_AnswerObjectType] FOREIGN KEY([AnswerTypeName])
REFERENCES [dbo].[AnswerObjectType] ([AnswerTypeName])
ALTER TABLE [dbo].[Stem] CHECK CONSTRAINT [FK_Question_AnswerObjectType]
ALTER TABLE [dbo].[UserStatus]  WITH CHECK ADD  CONSTRAINT [FK_Consent_aspnet_Users] FOREIGN KEY([UserId])
REFERENCES [dbo].[aspnet_Users] ([UserId])
ALTER TABLE [dbo].[UserStatus] CHECK CONSTRAINT [FK_Consent_aspnet_Users]